<!DOCTYPE html>
<html>
<head>
    <title>入院办理--中软高科-2015</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css"/>
    <link rel="stylesheet" type="text/css" href="../Css/style.css"/>
    <script type="text/javascript" src="/Js/jquery.js"></script>
    <script type="text/javascript" src="/Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }

        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
    <script type="text/javascript">


        function checkall2() {
            var alls = document.getElementsByName("check");
            var ch = document.getElementById("checkall");
            if (ch.checked) {
                for (var i = 0; i < alls.length; i++) {
                    alls[i].checked = true;
                }
            } else {
                for (var i = 0; i < alls.length; i++) {
                    alls[i].checked = false;
                }
            }
        }

        function delAll() {
            var alls = document.getElementsByName("check");
            var ids = new Array();
            for (var i = 0; i < alls.length; i++) {
                if (alls[i].checked) {
                    ids.push(alls[i].value);
                }
            }
            if (ids.length > 0) {
                if (confirm("确认操作?")) {
                    alert("成功!");
                }
            } else {
                alert("请选中要操作的项");
            }
        }
    </script>
</head>
<body>

<form id="myForm" method="post" class="definewidth m20">
    <table class="table table-bordered table-hover definewidth m10">
        <tr>
            <td width="10%" class="tableleft">病例号：</td>
            <td><input type="text" name="hosRRecode" value=""/></td>

            <td width="10%" class="tableleft">主治医生：</td>
            <td><input type="text" name="doctorName" value=""/></td>

            <td width="10%" class="tableleft">科室：</td>
            <td><input type="text" name="doctorKeshi" value=""/></td>
        </tr>
        <tr>

            <td width="10%" class="tableleft">住院时间：</td>

            <td colspan="5">
                <input type="date" name="beginTime" value=""/>&nbsp;至&nbsp;<input type="date" name="endTime" value=""/>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <button onclick="loadData()"  class="btn btn-primary" type="button">查询</button>
                <button  class="btn btn-primary" type="reset">清空</button>

            </td>
        </tr>
    </table>


<table class="table table-bordered table-hover definewidth m10">
    <thead>
    <tr>
        <th><input type="checkbox" id="checkall" onChange="checkall2();"></th>
        <th>病历号</th>
        <th>姓名</th>
        <th>床位号</th>
        <th>联系电话</th>
        <th>押金</th>
        <th>主治医生</th>
        <th>入院时间</th>
        <th>科室</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody id="tboby">
    <tr>
        <td style="vertical-align:middle;"><input type="checkbox" name="check" value="1"></td>
        <td style="vertical-align:middle;">1103</td>
        <td style="vertical-align:middle;">黄飞鸿</td>
        <td style="vertical-align:middle;">4343</td>
        <td style="vertical-align:middle;">13127653423</td>
        <td style="vertical-align:middle;">2000元</td>
        <td style="vertical-align:middle;">程俊</td>
        <td style="vertical-align:middle;">2015-01-05 12:33:56</td>
        <td style="vertical-align:middle;">血液科</td>
        <td style="vertical-align:middle;">已住院</td>
        <td style="vertical-align:middle;">
            <a href="look.html">详情>></a>&nbsp;&nbsp;&nbsp;
            <a href="edit.html">更改</a>&nbsp;&nbsp;&nbsp;
            <a href="add_many.html">缴纳押金</a>&nbsp;&nbsp;&nbsp;
        </td>
    </tr>
    <tr>
        <td style="vertical-align:middle;"><input type="checkbox" name="check" value="1"></td>
        <td style="vertical-align:middle;">1103</td>
        <td style="vertical-align:middle;">黄飞鸿</td>
        <td style="vertical-align:middle;">4343</td>
        <td style="vertical-align:middle;">13127653423</td>
        <td style="vertical-align:middle;">2000元</td>
        <td style="vertical-align:middle;">程俊</td>
        <td style="vertical-align:middle;">2015-01-05 12:33:56</td>
        <td style="vertical-align:middle;">血液科</td>
        <td style="vertical-align:middle;">已退院</td>
        <td style="vertical-align:middle;">
            <a href="look.html">详情>></a>&nbsp;&nbsp;&nbsp;
        </td>
    </tr>
    </tbody>
</table>

<table class="table table-bordered table-hover definewidth m10">


    <tr>
        <th colspan="5">
            <div style=" display: inline-block">
                <button type="button" class="btn btn-success" id="newNav">添加住院信息</button>&nbsp;&nbsp;&nbsp;
                <button type="button" class="btn btn-success" id="delPro" onClick="delAll();">出院</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <button type="button" class="btn btn-success" id="excel">导出Excel</button>
            </div>
            <!--分页部分-->
            <div style=" display: inline-block;margin-left: 100px">
                <div style="text-align: left;display: inline-block;">
                    <ul class="pagination" style="margin: 0;display: inline">
                        <li name="pageLi" id="firstPage" style="display: inline"><a href="#">首页</a></li>
                        <li name="pageLi" id="prePage" style="display: inline"><a href="#">上一页</a></li>
                        <li name="pageLi" id="nextPage" style="display: inline"><a href="#">下一页</a></li>
                        <li name="pageLi" id="lastPage" style="display: inline"><a href="#">末页</a></li>
                    </ul>
                </div>
                <label style="text-align: right;margin-left: 15px;display: inline-block">
                    共<span id="total"></span>条数据，共<span id="pages"></span>页
                </label>
                <label style="text-align: right;margin-left: 10px">
                    每页显示
                </label>
                <div style="text-align: right; padding:0;margin: 0; display: inline">
                    <select name="pageSize" id="pageSize" style="width: 80px;" onblur="loadData()">
                        <option value="5">5</option>
                        <option value="10">10</option>
                        <option value="15">15</option>
                    </select>
                </div>
                <label style="text-align: left;width: 87px;padding: 8px 5px;">
                    条数据
                </label>
                <label style="text-align: right;margin-left: 0px">
                    跳转到第
                </label>
                <div style="text-align: right; padding:0;margin: 0;display: inline">
                    <input onblur="loadData()" style="width: 50px" name="pageNum" id="pageNum" value="1"/>
                </div>
                <label style="text-align: left">页</label>
            </div>


        </th>
    </tr>
</table>

</form>

</body>
</html>
<script src="/layer/layer.js"></script>
<script src="/Js/getParameter.js"></script>
<script type="text/javascript">
    $(function () {
        loadData();
        $("ul[class='pagination']>li").click(function () {
            let num = $(this).attr("name");
            $("input[name='pageNum']").val(num);
            loadData();
        });
        //跳转添加页面
        $('#newNav').click(function () {
            window.location.href = "add.html";
        });
    });

    String.prototype.GetValue = function (para) {
        let reg = new RegExp("(^|&)" + para + "=([^&]*)(&|$)");
        let r = this.substr(this.indexOf("\?") + 1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    }

    //加载数据
    function loadData() {
        let url = document.location.toString();
        let pageNum = url.GetValue("pageNum");
        let pageSize = url.GetValue("pageSize");
        // alert(pageSize+","+pageNum);
        if (pageNum != null && $("input[name='pageNum']").val() != null) {
            $("input[name='pageNum']").val(pageNum);
        }
        if (pageSize != null && $("select[name='pageSize']").val() != null) {
            $("select[name='pageSize']").val(pageSize);
        }

        //alert($("#myForm").serialize())
        $.ajax({
            type: "GET",
            url: "/hospital/behospital/list",
            data: $("#myForm").serialize(),
            dataType: "json",
            success: function (vo) {
                // alert( "Data Saved: " + vo );
                let list = vo.pageInfo.list;
                //alert("Data lsit: " + list);
                let str = "";
                for (let i = 0; i < list.length; i++) {
                    let obj = list[i];
                    //住院信息
                    let behId = obj.behId;
                    let hosrRecode = obj.hosrRecode;
                    let behPatbed = obj.behPatbed;
                    let behAntecedent = obj.behAntecedent;
                    let behTime = obj.behTime;
                    let dName = obj.dName;
                    let behState = obj.behState == 0 ? "已住院" : "已出院";

                    //挂号信息
                    let register = obj.hosregister;
                    let hosrPhone = register.hosrPhone;
                    let dKeshi = register.dKeshi;
                    let hosrName = register.hosrName;


                    let btnStr = "";
                    if (obj.behState == 0) {
                        btnStr = ' <a href="look.html">详情>></a>&nbsp;&nbsp;&nbsp;\n' +
                            '            <a href="edit.html">更改</a>&nbsp;&nbsp;&nbsp;\n' +
                            '            <a href="add_many.html">缴纳押金</a>&nbsp;&nbsp;';
                    } else {
                        //continue
                        btnStr = ' <a href="look.html">详情>></a>&nbsp;&nbsp;&nbsp;\n' +
                            '            <a href="edit.html">更改</a>&nbsp;&nbsp;&nbsp;\n';
                    }
                    str += '<tr>\n' +
                        '        <td style="vertical-align:middle;"><input type="checkbox" name="check" value="1"></td>\n' +
                        '        <td style="vertical-align:middle;">' + hosrRecode + '</td>\n' +
                        '        <td style="vertical-align:middle;">' + hosrName + '</td>\n' +
                        '        <td style="vertical-align:middle;">' + behPatbed + '</td>\n' +
                        '        <td style="vertical-align:middle;">' + hosrPhone + '</td>\n' +
                        '        <td style="vertical-align:middle;">' + behAntecedent + '</td>\n' +
                        '        <td style="vertical-align:middle;">' + dName + '</td>\n' +
                        '        <td style="vertical-align:middle;">' + behTime + '</td>\n' +
                        '        <td style="vertical-align:middle;">' + dKeshi + '</td>\n' +
                        '        <td style="vertical-align:middle;">' + behState + '</td>\n' +
                        '        <td style="vertical-align:middle;">' + btnStr + '</td>\n' +
                        '    </tr>';
                }

                $("#tboby").html(str);
                //填充分页数据

                fillPageData(vo.pageInfo);
            }
        });
    }

    //填充数据
    function fillPageData(pageInfo) {

        //填充信息
        $("#total").html(pageInfo.total);
        $("#pages").html(pageInfo.pages);
        $("input[name='pageNum']").val(pageInfo.pageNum);
        $("select[name='pageSize']").val(pageInfo.pageSize);
        //设置按钮的属性值和样式
        $("#firstPage").attr("name", 1);
        $("#prePage").attr("name", pageInfo.prePage);
        $("#nextPage").attr("name", pageInfo.nextPage);
        $("#lastPage").attr("name", pageInfo.pages);
        $("#firstPage").removeClass("disabled");
        $("#prePage").removeClass("disabled");
        $("#firstPage").removeClass("disabled");
        $("#prePage").removeClass("disabled");
        if (pageInfo.isFirstPage) {//如果是第一页：上一页和首页禁用
            $("#firstPage").addClass("disabled");
            $("#prePage").addClass("disabled");
        }
        if (pageInfo.isLastPage) {//如果已经是最后一页：下一页和末页禁用
            $("#nextPage").addClass("disabled");
            $("#lastPage").addClass("disabled");
        }
    }

</script>